package com.zzlzd.drp.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface AccountRepository extends JpaRepository<AccountDto,Integer> {

    /***
     * 根据用户账号查找用户信息
     * @param username
     * @return
     */
    @Query(nativeQuery=true, value=" SELECT * FROM account WHERE account = ?1  LIMIT 1 ")
    public AccountDto findAdmin(String username);

    @Query(nativeQuery=true, value=" SELECT COUNT(id) FROM account WHERE account = ?1  ")
    public int isTrue(String groupAccount);

    /***
     * 查找指定团队所有人员
     * @param id
     * @return
     */
    @Query(nativeQuery=true, value=" SELECT * FROM account WHERE group_id = ?1 AND state = 0")
    public List<AccountDto> findGroupAll(Integer id);
}
